#Figure A3
mean(mydata$n, na.rm=TRUE)
mean(mydata$unauth_share, na.rm=TRUE)

range(mydata$n, na.rm=TRUE)
range(mydata$unauth_share, na.rm=TRUE)


png(file="Figures/figureA3.png", height=5, width=9, units="in", res=800)  
lab <- c(2007, rep(NA, 11), 2008, rep(NA, 11), 2009, rep(NA, 11), 2010, rep(NA, 11), 2011, rep(NA, 11), 2012, rep(NA, 11), 2013, rep(NA, 11), 2014, rep(NA, 11), 2015, rep(NA, 11), 2016, rep(NA, 11), 2017, rep(NA, 11),2018, rep(NA, 11)) 

plot(mydata$n, lwd=2, type= "l", xaxt="n", xlab="", ylab="", ylim=c(0,150))

lines(mydata$n, type="l", lwd=2, lty=1, col="blue", pch=23)
lines(mydata$unauth_share, type="l", lwd=2, lty=1, col="red", pch=23)

title(ylab="",col.main="black", font.main=2)

#key events
arrows(12, -25, 12, 136, length = 0, col="black", lty=3, lwd=2)
arrows(15, -25, 15, 127, length = 0, col="black", lty=3, lwd=2)
arrows(60, -25, 60, 135, length = 0, col="black", lty=3, lwd=2)
arrows(63, -25, 63, 119, length = 0, col="black", lty=3, lwd=2)
arrows(86, -25, 86, 86, length = 0, col="black", lty=3, lwd=2)
arrows(117, -25, 117, 86, length = 0, col="black", lty=3, lwd=2)
arrows(135, -25, 135, 100, length = 0, col="black", lty=3, lwd=2)

labels <- c("Duma election", "Presidential", "Duma", "Presidential", "Crimea", "Duma", "Presidential")
text(c(11+1, 16+5, 59+4, 62+8, 86+2, 117+1, 135+1), c(142, 131, 140, 125, 90, 90, 105), labels=labels)
axis(1, 1:144, labels=lab)

legend("topright", c("Monthly Protests Count", "% Unauthorized Protests"), bty='n',
       lty=c(1,1,1), lwd=c(1.5,1.5,1.5), col=c("blue", "red"), cex=1) 

dev.off()